/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * Player Entity for database and queries for database communication.
 * @author Rodge Uy
 */
@Entity
@Table(name = "Player")
@NamedQueries({
    @NamedQuery(name = "Player.findAll", query = "SELECT p FROM Player p"),
    @NamedQuery(name = "Player.findAllNotPlayer", query = "SELECT p FROM Player p WHERE p.playName <> :playerName"),
    @NamedQuery(name = "Player.findByPlayName", query = "SELECT p FROM Player p WHERE p.playName = :playName"), 
    @NamedQuery(name = "Player.findByFurthestPlayedLevel", query = "SELECT p FROM Player p WHERE p.furthestPlayedLevel = :furthestPlayedLevel"), 
    @NamedQuery(name = "Player.findByAccumScore", query = "SELECT p FROM Player p WHERE p.accumScore = :accumScore"), 
    @NamedQuery(name = "Player.findByPlayerNamePassWord", query = "SELECT p FROM Player p WHERE p.passWord = :passWord AND p.playName =:playName"),
    @NamedQuery(name = "Player.updateLevelAndScore", query = "UPDATE Player p SET p.accumScore =:accumScore, p.furthestPlayedLevel =:furthestPlayedLevel WHERE p.playName =:playName"),
    @NamedQuery(name = "Player.updateOnlineStatus", query = "UPDATE Player p SET p.isOnline =:isOnline WHERE p.playName =:playName"),
    @NamedQuery(name = "Player.updateUserInfo", query = "UPDATE Player p SET p.email =:email, p.passWord = :password WHERE p.playName =:playName"),
    @NamedQuery(name = "Player.updatePicture", query = "UPDATE Player p SET p.picture =:picture WHERE p.playName =:playName")
})
public class Player implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "playName")
    private String playName;
    @Basic(optional = false)
    @Column(name = "FurthestPlayedLevel")
    private int furthestPlayedLevel;
    @Basic(optional = false)
    @Column(name = "AccumScore")
    private int accumScore;
    @Basic(optional = false)
    @Column(name = "passWord")
    private String passWord;
    @Basic(optional = false)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @Column(name = "picture")
    private int picture;
    @Basic(optional = false)
    @Column(name = "isOnline")
    private int isOnline;


    public Player() {
    }

    public Player(String playName) {
        this.playName = playName;
    }

    public Player(String playName, int furthestPlayedLevel, int accumScore, String passWord, String email, int picture, int isOnline) {
        this.playName = playName;
        this.furthestPlayedLevel = furthestPlayedLevel;
        this.accumScore = accumScore;
        this.passWord = passWord;
        this.email = email;
        this.picture = picture;
        this.isOnline = isOnline;
    }

    public String getPlayName() {
        return playName;
    }

    public void setPlayName(String playName) {
        this.playName = playName;
    }

    public int getFurthestPlayedLevel() {
        return furthestPlayedLevel;
    }

    public void setFurthestPlayedLevel(int furthestPlayedLevel) {
        this.furthestPlayedLevel = furthestPlayedLevel;
    }

    public int getAccumScore() {
        return accumScore;
    }

    public void setAccumScore(int accumScore) {
        this.accumScore = accumScore;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getPicture() {
        return picture;
    }

    public void setPlayName(int picture) {
        this.picture = picture;
    }

    public int getIsOnline() {
        return isOnline;
    }

    public void setIsOnline(int isOnline) {
        this.isOnline = isOnline;
    }


    @Override
    public int hashCode() {
        int hash = 0;
        hash += (playName != null ? playName.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Player)) {
            return false;
        }
        Player other = (Player) object;
        if ((this.playName == null && other.playName != null) || (this.playName != null && !this.playName.equals(other.playName))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Player[playName=" + playName + "]";
    }

}
